package com.wenyu.wenyuyuedu.adapter.homepagefragment;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.wenyu.wenyuyuedu.R;
import com.wenyu.wenyuyuedu.view.CircleImageView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/2/27.
 * 打赏者头像的显示
 */

public class PlaytourCountAdapter extends BaseAdapter {
    private Context context;
    private List<String> mList;
    private CircleImageView playtour;
    private PlaytourCountAdapter.playtourHolder playtourHolder;
    private View inflate;

    public PlaytourCountAdapter(Context context) {
        this.context = context;
        mList = new ArrayList<>();
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        playtourHolder = null;
        if (view != null) {
            return view;
        }
        if(view == null){
            inflate = View.inflate(context, R.layout.playtour_count_item, null);
            playtour = (CircleImageView) inflate.findViewById(R.id.iv_playtour);
            if(mList.size() > 0){
                playtour.setVisibility(View.VISIBLE);
            }
            Glide.with(context)
                    .load(mList.get(i))
                    .into(playtour);

        }

        return inflate;
    }

    class playtourHolder {
        ImageView iv_playtour;
    }

    public void addPlaytourAll(List<String> list) {
        mList.clear();
        mList.addAll(list);
        notifyDataSetChanged();
    }
}
